use bigdecimal::BigDecimal;
use std::str::FromStr;

/// 币 也就是区块链所承载的信息 也就是账本
#[derive(Debug)]
pub struct Coin {
    from: String,
    to: String,
    count: BigDecimal,
    signature: Option<String>,
}

impl Coin {
    /// 新增
    pub fn new(to: &str, count: &str) -> Self {
        Coin {
            from: "".to_string(),
            to: to.to_string(),
            count: BigDecimal::from_str(count).unwrap(),
            signature: None,
        }
    }

    ///传递
    pub fn from(from: &str, to: &str, count: &str, signature: String) -> Self {
        Coin {
            from: from.to_string(),
            to: to.to_string(),
            count: BigDecimal::from_str(count).unwrap(),
            signature: Some(signature),
        }
    }
}